import { HOME_URL, LOGIN_URL } from "@/config";
import type { RouteRecordRaw } from "vue-router";

/**
 * @description 静态路由
 */
export const staticRouter: RouteRecordRaw[] = [
  {
    path: "/",
    redirect: "/layout"
  },
  {
    path: LOGIN_URL,
    name: "login",
    component: () => import("@/views/login/index.vue"),
    meta: { title: "登录" }
  },
  {
    path: "/layout",
    name: "layout",
    redirect: "dashboard",
    component: () => import("@/layouts/index.vue"),
    children: [
      {
        path: HOME_URL,
        name: "Dashboard",
        component: () => import("@/views/dashboard/index.vue"),
        meta: {
          title: "工艺规程管理",
          icon: "gongzuotai",
          isHidden: false,
          isKeepAlive: false,
          isAffix: true,
          activeMenu: true
        }
      },
      {
        path: "/craftRuleDetails/:id/:name",
        name: "CraftRuleDetails",
        component: () => import("@/views/details/index.vue"),
        beforeEnter: (to, from, next) => {
          to.meta.title = to.params.name as string;
          next();
        },
        meta: {
          title: "详细信息",
          icon: "gongzuotai",
          isHidden: true,
          isKeepAlive: false,
          isAffix: false,
          activeMenu: false
        }
      },
      {
        path: "/userCentre",
        name: "userCentre",
        component: () => import("@/views/userCentre/index.vue"),
        meta: {
          title: "个人中心",
          icon: "user-outlined",
          isHidden: true,
          isKeepAlive: true,
          isAffix: false,
          activeMenu: false
        }
      }
    ]
  }
];

/**
 * @description 错误页面路由
 */
export const errorRouter: RouteRecordRaw[] = [
  {
    path: "/403",
    name: "403",
    component: () => import("@/components/Exception/403.vue"),
    meta: {
      title: "403页面"
    }
  },
  {
    path: "/404",
    name: "404",
    component: () => import("@/components/Exception/404.vue"),
    meta: {
      title: "404页面"
    }
  },
  {
    path: "/500",
    name: "500",
    component: () => import("@/components/Exception/500.vue"),
    meta: {
      title: "500页面"
    }
  },
  {
    path: "/:pathMatch(.*)*",
    component: () => import("@/components/Exception/404.vue")
  }
];
